package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.pojo.Order;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

public interface OrderMapper extends BaseMapper<Order> {
    @Select("select count(1) " +
            "from order_t " +
            "where setmeal_id = #{setmealid}  and member_id = #{mid}  and  order_date = #{orderDate}")
    int isGenerateOrderOrNot(@Param("setmealid") long setmealid, @Param("mid") Long mid, @Param("orderDate") String orderDate);

    @Select("SELECT mt.name as member , smt.name as setmeal,ort.order_date as orderDate,ort.order_type as orderType " +
            "FROM order_t ort,setmeal_t smt , member_t mt " +
            "where ort.setmeal_id = smt.id and ort.member_id = mt.id " +
            "and ort.id =#{id}")
    Map findOrderInfoById(@Param("id") long id);
}
